// global variable to check the status of the flipper hold button press
bool FlipperHoldButton = false;
// global variable to hold the gyro value
int FlipperGyroValue = 1;

// add this as one of the functions that gets called in the infinite loop in the user control section of the code
void FlipperHold()
{
  if(vexRT(Btn8UXmtr2) == true)
  {
    if (FlipperHoldButton == true)
    {
      // turn off the hold
      StopTask(FlipperGyroHold);
      FlipperHoldButton = false;
    }
    else
    {
      // turn on the hold
      StartTask(FlipperGyroHold);
      FlipperHoldButton = true;
    }
  }
  else
  {
    // if the button is not pressed, do nothing (until the button is pressed again)
  }
}

task FlipperGyroHold()
{
  // get the current value of the gyro so we know where to hold the flipper
  FlipperGyroValue = SensorValue(FlipperGyro);
  // start holding the flipper in place - enter an infinite loop (until stop task is called, the code in here will continue to operate)
  while(true)
  {
    // do whatever you need to do to keep the flipper near the value
    if(SensorValue(FlipperGyro) < FlipperGyroValue)
    {
      motor(FlipperMotorRight) += 5;
      motor(FlipperMotorLeft) += 5;
    }
    if(SensorValue(FlipperGyro) > FlipperGyroValue)
    {
      motor(FlipperMotorRight) -= 5;
      motor(FlipperMotorLeft) -= 5;
    }
  }
}